﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Text;
using ByteSite.Common;

namespace ByteSite.BLL
{
    /// <summary>
    ///物流快递
    /// </summary>
    public partial class custom_list
    {
        private readonly Entitys.sysconfig sysConfig = new BLL.sysconfig().loadConfig();//获得系统配置信息
        private readonly DAL.Data data;

        public custom_list()
        {
            data = new DAL.Data();
        }

        #region 基本方法================================
        /// <summary>
        /// 是否存在该记录
        /// </summary>
        public bool Exists(int id)
        {
            return data.Exists<Entitys.dt_custom_list>(id);
        }

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Entitys.dt_custom_list model)
        {
            return data.Insert<Entitys.dt_custom_list>(model);
        }

        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Entitys.dt_custom_list model)
        {
            return data.Update(model);
        }

        /// <summary>
        /// 删除一条数据
        /// </summary>
        public bool Delete(int id)
        {
            return data.Delete<Entitys.dt_custom_list>(id);
        }

        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Entitys.dt_custom_list GetModel(int id)
        {
            return data.Get<Entitys.dt_custom_list>(id);
        }

        /// <summary>
        /// 获得前几行数据
        /// </summary>
        public List<Entitys.dt_custom_list> GetList(int top, Expression<Func<Entitys.dt_custom_list, bool>> whereExpression, Expression<Func<Entitys.dt_custom_list, object>> orderExpression)
        {
            return data.List<Entitys.dt_custom_list>(top, whereExpression, orderExpression);
        }

        public List<Entitys.dt_custom_list> GetList(Expression<Func<Entitys.dt_custom_list, bool>> whereExpression, Expression<Func<Entitys.dt_custom_list, object>> orderExpression)
        {
            return data.List<Entitys.dt_custom_list>(whereExpression, orderExpression);
        }

        /// <summary>
        /// 获得查询分页数据
        /// </summary>
        public List<Entitys.dt_custom_list> GetList(int pageSize, int pageIndex, Expression<Func<Entitys.dt_custom_list, bool>> whereExpression, Expression<Func<Entitys.dt_custom_list, object>> orderExpression, out int recordCount)
        {
            return data.List<Entitys.dt_custom_list>(pageSize, pageIndex, whereExpression, orderExpression, out recordCount);
        }
        #endregion


        /// <summary>
        /// 保存排序
        /// </summary>
        public bool UpdateSort(int id, int sort_id)
        {
            return data.UpdateColumns<Entitys.dt_custom_list>(x => x.sort_id == sort_id, x => x.id == id);
        }
    }
}